package com.tomatozq163;

import java.awt.*;

public class Circle {
    public int x,y;
    private int r;
    public int vx,vy;
    public boolean isFilled;

    public Circle(int x, int y, int r, int vx, int vy) {
        this.x = x;
        this.y = y;
        this.r = r;
        this.vx = vx;
        this.vy = vy;
        this.isFilled = false;
    }

    public int getR() {
        return r;
    }

    public void move(int minx,int maxx,int miny,int maxy){
        x += vx;
        y += vy;

        checkCollision(minx,maxx,miny,maxy);
    }

    private void checkCollision(int minx,int maxx,int miny,int maxy){
        if (x -r <minx){
            x = r;
            vx = -vx;
        }

        if (x + r >= maxx){
            x = maxx - r;
            vx = -vx;
        }

        if (y-r <minx){
            y = r;
            vy = -vy;
        }

        if (y + r >= maxy){
            y = maxy - r;
            vy = -vy;
        }
    }

    public boolean contain(Point point) {
        double distance = Math.pow(point.x-x,2) + Math.pow(point.y-y,2);

        if (distance > r*r){
            return false;
        }
        else{
            return true;
        }
    }
}
